﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Data;
using ViewComponents.PowerPoint;
using ViewComponents.PowerPoint.ViewModels;

namespace ViewComponents.Converters
{
    public class ViewModelTypeToControlConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null) return null;

            if (value is ConstantSourceObjectViewModel)
                return new ConstantSourceObjectControl();
            else if (value is ExcelSourceObjectViewModel)
                return new ExcelSourceObjectControl();
            else
                throw new InvalidOperationException("ViewModel type is not valid.");
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return DependencyProperty.UnsetValue;
        }
    }
}
